#include<QTimer>
#include<QPaintEvent>
#include<QWidget>
QT_BEGIN_NAMESPACE
namespace Ui { class dazuoye; }
QT_END_NAMESPACE

typedef enum Direct{
    DIR_LEFT,
    DIR_RIGHT,
    DIR_UP,
    DIR_DOWN
}dir_t;

class dazuoye : public QWidget
{
    Q_OBJECT

public:
    dazuoye(QWidget *parent = nullptr);
    ~dazuoye();
protected:
    void paintEvent(QPaintEvent*event);
    void addTop();
    void addDown();
    void addRight();
    void addLeft();
    void addNewReword();
    bool checkContact();
    void keyPressEvent(QKeyEvent*event);
    void deleteLast();

private:
    Ui::dazuoye *ui;
    int moveFlag =DIR_UP;
    bool gameStart = false;
    QTimer *timer;
    int time=100;
    QList <QRectF> snake;
    QRectF rewardNode;
    int nodeWidth=20;
    int nodeHeight=20;
protected slots:
    void  timeout();


};
#if defined(DEBUG)
#endif// DAZUOYE_H



